package com.bawei.module_home.model

import android.graphics.Color
import com.bawei.lib_common.utils.TimeUtils

//data class SignResult(
//    val code: Int,
//    val `data`: Data,
//    val message: String
//)

data class SignResult(
    val afternoonCheckIn: String,
    val currentLocation: String,
    val id: Int,
    val location: String,
    val morningCheckIn: String,
    val status: String,
    val userId: Int
){
    fun getDate():String{
        if (morningCheckIn.isEmpty() && afternoonCheckIn.split(" ").size > 1){
            val date = afternoonCheckIn.split(" ")[0]
            return TimeUtils.formatDateToChinese(date)
        }else if (afternoonCheckIn.isEmpty() && morningCheckIn.split(" ").size > 1){
            val date = morningCheckIn.split(" ")[0]
            return TimeUtils.formatDateToChinese(date)
        }
        return "2025年6月16日"
    }
    fun getTime():String{
        var morning=""
        var afternoon=""
        if (morningCheckIn.isEmpty() && afternoonCheckIn.split(" ").size > 1){
            afternoon = afternoonCheckIn.split(" ")[1].substringBeforeLast(":")
        }else if (afternoonCheckIn.isEmpty() && morningCheckIn.split(" ").size > 1){
            morning = morningCheckIn.split(" ")[1].substringBeforeLast(":")
        }
        return "上班 $morning - 下班 $afternoon"
    }
    fun getSignStatus():String{
        return when(status){
            "0"->"正常"
            "1"->"迟到"
            "2"->"早退"
            "3"->"缺勤"
            else->"异常"
        }
    }
    fun getStatusBackgroundColor():Int{
        return when(status){
            "0"->Color.parseColor("#1A52C41A")
            "1"->Color.parseColor("#1AF5A623")
            "2"->Color.parseColor("#1A1890FF")
            "3"->Color.parseColor("#1AFF4D4F")
            else->Color.parseColor("#FFFFFF")
        }
    }
    fun getStatusTextColor():Int{
        return when(status){
            "0"->Color.parseColor("#52C41A")
            "1"->Color.parseColor("#F5A623")
            "2"->Color.parseColor("#1890FF")
            "3"->Color.parseColor("#FF4D4F")
            else->Color.parseColor("#000000")
        }
    }

}